<!--
 * @Author: your name
 * @Date: 2021-12-29 02:48:59
 * @LastEditTime: 2022-01-04 22:47:22
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /ac_interface/src/views/Login.vue
-->
<!--
 * @Author: your name
 * @Date: 2021-12-29 02:28:30
 * @LastEditTime: 2021-12-29 02:47:44
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /ac_interface/src/Login2.vue
-->

<template>
    <div class="login-container">
        <el-form :model="ruleForm2" :rules="rules2"
         status-icon
         ref="ruleForm2" 
         label-position="left" 
         label-width="0px" 
         class="demo-ruleForm login-page">
             <h3 class="title">系统登录</h3>
            <el-form-item prop="username">
                <el-input type="text" 
                    v-model="ruleForm2.username" 
                    auto-complete="off" 
                    placeholder="用户名"
                ></el-input>
            </el-form-item>
                <el-form-item prop="password">
                    <el-input type="password" 
                        v-model="ruleForm2.password" 
                        auto-complete="off" 
                        placeholder="密码"
                    ></el-input>
                </el-form-item>
            <el-form-item style="width:100%;">
                <el-button type="primary" style="width:100%;" @click="handleLink" :loading="logining">登录</el-button>
            </el-form-item>  
        </el-form>
    </div>
</template>

<script>

import { login } from '../api/users.js';
export default {
    data(){
        return {
            logining: false,
            
            ruleForm2: {
                username: 'yzc',
                password: '123456',
            },
            rules2: {
                username: [{required: true, message: 'please enter your account', trigger: 'blur'}],
                password: [{required: true, message: 'enter your password', trigger: 'blur'}]
            },
            checked: false,
            vmrole:''
        }
    },
    methods:{
        handleLink(){
            let ret={};
            ret=login(this.ruleForm2.username,this.ruleForm2.password);
            alert(ret.vmRole);
            if(ret.code==1){
                this.$router.push({path: '/Admin',
                query:{
                    username:this.ruleForm2.username,
                    password:this.ruleForm2.password,
                }
                });
                return;
            }
            if(ret.code!=-1){        
                this.$router.push({path: '/Terminal',
               query:{
                   username:this.ruleForm2.username,
                   password:this.ruleForm2.password,
                   vmrole:ret.vmRole,
               }
                 });
           }         
        },
    }
};
</script>

<style scoped>
.login-container {
    width: 100%;
    height: 100%;
}
.login-page {
    -webkit-border-radius: 5px;
    border-radius: 5px;
    margin: 180px auto;
    width: 350px;
    padding: 35px 35px 15px;
    background: #fff;
    border: 1px solid #eaeaea;
    box-shadow: 0 0 25px #cac6c6;
}
label.el-checkbox.rememberme {
    margin: 0px 0px 15px;
    text-align: left;
}
</style>
